<?php
/**
 * 
 * CodeSpace Client View Helper
 * 
 * @access public
 * @package CodeSpace Client
 * @subpackage Client
 * @author Hüseyin Deniz KIVRAK <huseyindeniz@mikrobeta.com.tr>
 */
class CodeSpace_Client_View_Helper_Client extends Zend_View_Helper_Abstract
{
    /**
     * Client 
     * 
     * @var CodeSpace_Client_View_Helper_Client client
     */
    protected $_client = 'undefined';
    
    /**
     * subClient 
     * 
     * @var CodeSpace_Client_View_Helper_Client subclient
     */
    protected $_subClient = 'undefined';
    
    /**
     * options 
     * 
     * @var CodeSpace_Client_View_Helper_Client options
     */
    protected $_options = array();
    
    /**
     * 
     * client()
     * 
     * return this
     * 
     * @author Hüseyin Deniz KIVRAK <huseyindeniz@mikrobeta.com.tr>
     * @access public
     * @return CodeSpace_Client_View_Helper_Client
     */
    public function client()
    {
        return $this;
    }

    /**
     * 
     * getClient()
     * 
     * return current client
     * 
     * @author Hüseyin Deniz KIVRAK <huseyindeniz@mikrobeta.com.tr>
     * @access public
     * @return CodeSpace_Client_View_Helper_Client client
     */
    public function getClient()
    {
        return $this->_client;
    }

    /**
     * 
     * getClients()
     * 
     * return avaliable clients
     * 
     * @author Hüseyin Deniz KIVRAK <huseyindeniz@mikrobeta.com.tr>
     * @access public
     * @return CodeSpace_Client_View_Helper_Client client[]
     */
    public function getClients()
    {
        return $this->_options['client']['sub'];
    }

    /**
     * 
     * hasSubClient()
     * 
     * return true if current client has subclients
     * else false
     * 
     * @author Hüseyin Deniz KIVRAK <huseyindeniz@mikrobeta.com.tr>
     * @access public
     * @return boolean
     */
    public function hasSubClient()
    {
        if(array_key_exists($this->_client, $this->_options)){
            return true;
        }else {
            return false;
        }
    }

    /**
     * 
     * getSubClient()
     * 
     * return current subclient
     * 
     * @author Hüseyin Deniz KIVRAK <huseyindeniz@mikrobeta.com.tr>
     * @access public
     * @return CodeSpace_Client_View_Helper_Client subClient
     */
    public function getSubClient()
    {
        return $this->_subClient;    
    }

    /**
     * 
     * getSubClients()
     * 
     * return avaliable subclients of current client
     * 
     * @author Hüseyin Deniz KIVRAK <huseyindeniz@mikrobeta.com.tr>
     * @access public
     * @return CodeSpace_Client_View_Helper_Client subclient[]
     */
    public function getSubClients()
    {
        if($this->hasSubClient())
        {
            return $this->_options[$this->_client]['subclients'];
        }else {
            return array();
        }
    }

    /**
     * 
     * setClient()
     * 
     * set current client
     * 
     * @author Hüseyin Deniz KIVRAK <huseyindeniz@mikrobeta.com.tr>
     * @access public
     * @param CodeSpace_Client_View_Helper_Client client
     * @return CodeSpace_Client_View_Helper_Client
     */
    public function setClient($client)
    {
        if(in_array($client, $this->_options['clients']))
        {
            $this->_client = $client;
            return true;
        }else {
            return false;
        }
        return $this;
    }

    /**
     * 
     * setSubClient()
     * 
     * set current subclient of current client
     * 
     * @author Hüseyin Deniz KIVRAK <huseyindeniz@mikrobeta.com.tr>
     * @access public
     * @param CodeSpace_Client_View_Helper_Client subclient
     * @return boolean
     */
    public function setSubClient($subclient)
    {
        if($this->hasSubClient()){
            if(in_array($subclient, $this->_options[$this->_client]['subclients'])){
                $this->_subClient = $subclient;
                return true;
            }else {
                if($subclient==''){
                    $this->_subClient = '';
                    return true;   
                }else 
                {
                    return false;
                }
            }
        }else {
            $this->_subClient = '';
            return true;
        }
    }

    /**
     * 
     * setOptions()
     * 
     * return this
     * 
     * @author Hüseyin Deniz KIVRAK <huseyindeniz@mikrobeta.com.tr>
     * @access public
     * @param options[]
     * @return CodeSpace_Client_View_Helper_Client
     */
    public function setOptions($options)
    {
        $this->_options = $options['client']['sub'];
        var_dump($this->_options);
        //exit;
        return $this;
    }
    
}
